#ifndef __LED_H__
#define __LED_H__

#include "device.h"

#ifdef __cplusplus
extern "C" {
#endif

// LED结构体
DEVICE_FEATURE_DECLARE
(
    Led,

    struct {
        /**
         * @brief LED输出状态
         * @param u8State 0/1
         */
        void (*pfnWrite)(uint8_t u8State);
    },

    struct {
        uint8_t u8Active;       // 有效状态
        uint8_t u8State;        // 当前状态
        uint16_t u16Reserved;   // 保留字段
    }
);

/**
 * @brief LED设备注册
 * @param pstSelf LED设备结构体
 * @return Device_t* 注册成功返回设备结构体指针，失败返回NULL
 */
DEV_REG_DEC(led, Led_t)

/**
 * @brief 点亮LED
 * @param pstDevice LED设备
 * @return @see DEV_RET_t
*/
DEV_RET_t
led_on(Device_t *pstDevice);

/**
 * @brief 熄灭LED
 * @param pstDevice LED设备
 * @return @see DEV_RET_t
*/
DEV_RET_t
led_off(Device_t *pstDevice);

/**
 * @brief 反转LED状态
 * @param pstDevice LED设备
 * @return @see DEV_RET_t
*/
DEV_RET_t
led_toggle(Device_t *pstDevice);

#ifdef __cplusplus
}
#endif

#endif /* __LED_H__ */
